rmvxacefandomcom-20200213-history
Damage Formula Reference Guide
Under Construction This page provides a concise reference guide on how to create your own damage formulas in RPG Maker VX Ace. Moderate familiarity with RPG Maker VX Ace project editor is required. Basic arithmetic skill and intermediate algebra are recommended. Overview RPG Maker VX Ace lets developers create their own custom damage formula for each Item and Skill in their database. Formulas must adhere to Ruby syntax rules even though this requirement isn't explicitly stated. You do not need any prior programming experience in order to make your own formulas. However, the purpose of this guide is to introduce basic Ruby syntax and concepts so that you can make the most out the "Formula" field. How to read examples Examples will include a Ruby statement and their outputs in the associated "comment". Comments are preceded by the "#" symbol and are not meant to be explicitly typed in the formula box. Imagine that you're using a simple calculator and you input the following: 3 + 2 The answer is, of course, "5". But when creating your damage formula, the output is implied. In order to make examples in this guide clear, the output will be explicitly stated within an associated comment on the same line. 3 + 2 # => 5 Again, comments are not meant to be explicitly typed in the formula box. Basic Data Types 'Integers' Integers are whole number values with no significant figures. Negative integers are preceded by the negative sign with no space between the sign and the numerical value. In other words, what you see is what you get (in base 10). 1 -502 1234567890 ''Avoid leading zeroes Numerical values that precede with "0" are ''not integers. Instead, values that start with "0" are treated as octal values. For example: 0567 # => 375 Unless you actually want to use octal values, avoid using leading zeroes. 'Floating Point Values' Floating point values (float for short) are values with any number of significant figures. Negative floats are preceded by the negative sign with no space between the sign and the numerical value. 1.0 -502.0 12345.6789 Ruby does not allow floating literals with no value before the dot. .5 # => ERROR! If a value is less than 1.0, then place one 0 before the dot. 0.5 # => 0.5 Arithmetic Operators The four basic arithmetic operators should be self-explanatory, but are explained with Ruby syntax rules in mind. The [http://en.wikipedia.org/wiki/Order_of_operations order of operations] for mathmatical calculations are implied in all cases. Spaces are recommended between any operands (i.e. values) and the operator. 'Addition (+)' Addition uses the plus sign "+". 3 + 2 # => 5 4 + -1 # => 3 The sum of integers and floats will always be a float. 5 + 10.0 # => 15.0 'Subtraction (-)' Subtraction uses the minus sign "-". 3 + 2 # => 5 4 - -1 # => 5 The difference of integers and floats will always be a float. 5 - 10.0 # => -5.0 'Multiplication (*)' Multiplication uses the asterisk "*". 3 * 2 # => 6 4 * -1 # => -4 The product of integers and floats will always be a float. 5 * 10.0 # => 50.0 'Division (/)' Division uses forward slash "/". The "\" or "back slash" is not interchangeable with the "forward slash" sign. 100 / 5 # => 20 3.0 / 4.0 # => 0.75 The quotient's data type differs depending on the data types of the operands. ''Division with Integer Operands 3 / 2 # => 1 "3 divided by 2" should result in a value less than 2 and more than 1. However, the quotient of two integer operands will always be an integer. Since quotient in this example does not normally result as an integer, it is rounded down to the nearest integer. In this case, it is 1. Division with Integer and Float Operands 3 / 2.0 # => 1.5 Producing a quotient with significant digits requires that at least one of the operands is a float. Dividing by zero 3 / 0 # => ERROR! As explored in any pre-algebra class, dividing by 0 results as "undefined". Correspondingly, dividing by 0 in Ruby will throw in an error. 'Exponents (**) Exponents are defined with double asterisks "**". Thus, 3² in Ruby becomes: 3 ** 2 # => 9 '''Modulo/Modulus (%) Modulo operations use the "%" sign or percent sign. 5 % 2 # => 1 4 % -1 # => 0 "A % B" is equivalent to: A – B * (A / B) In other words, a single modulo operator is equivalent to using three arithmetic operations with two operands. If you're still unclear on modulo, recall first learning about division. You likely practiced division by doing long division with remainders. The modulo operator returns the value of the remainder rather than quotient. 150 % 11 # => 7 'Parentheses' Parentheses are allowed in damage formulas and behaves similarly in modifying the order of operations. You must have a closing bracket for each opening bracket. Parentheses cannot be used as alternative syntax for multiplication. 5(5) # => ERROR! Damage Formula Box Damage formula boxes only appear under the database's "Skills" and "Items" tabs. This reference guide is mainly for what can be defined in the "Formula" field, but other fields are explained for clarity.. 'Type' The effect type on HP/MP. Specify one of the six available types. Damage reduces HP/MP, Recover raises HP/MP, Drain transfers HP/MP from target to user (the amount drained will be subtracted from the target and added to the user). If set to "None", the Skill/Item will deal no damage. HP/MP Drain will drain an amount equal to the damage dealt to the target. 'Element' Damage element. Final damage varies depending on the target's resistance to the element in question. A Skill/Item may only have one element. ''"Normal Attack" Element If the element is set to "Normal Attack", then the Skill/Item element will be the user's normal attack element. Normal attack elements are modified by the "Atk Element" Feature. 'Formula' A formula for calculating basic damage. Adjustments for such things as elements and defense will be made separately, so do not include them in the formula. The user is expressed by a and the target by b, and then either one is followed by a period to enable the referencing of the parameters shown hereafter. For example, "a.atk" stands for "user's attack power." To directly enter a formula, use the character strings shown in the table below to specify parameters you want to look up. To look up the attacker's parameters, change "x" to "a", and to look up the target's parameters, change "x" to "b". The string "a.atk" looks up the attacker's ATK parameter. Entering "a.atk * 4 - b.def * 2" specifies that the damage dealt will be the value calculated by (attacker's ATK × 4) - (target's DEF × 2). Some parameters that you can reference, but not limited to are: Replace "x" with either "a" or "b". It is also possible to reference a variable's nth value using vn Damage Formula Character Limit The "Formula" box has a maximum character limit of 100. However, this limit can be overcome by using custom scripts. Formula errors There are two possible outcomes whenever a syntax error or other general error occurs when processing a damage formula: #An error notification window appears, throws a syntax error, and shuts down the Game.exe. #The damage result is set to 0 and the Game.exe continues processing. Since outcome number 2 is not explicit about the error, it is easy to become confused as to why a skill or item isn't causing damage. 'Variance'. The degree of variability (0 to 100%). The value of the calculated damage will vary by the percentage value you specify here. For example, if damage was calculated to be 100 and variance was set to 20, the final damage would be between 80 and 120 (100 ± 20). 'Critical' Specify whether to enable critical hits by selecting '''Yes' or No. When you select Yes, critical hits will be determined based on the user's critical rate and the target's critical avoidance rate. 'Quick Damage Setting' Clicking the "Quick..." button will open up the Quick Damage Setting window. Utilizing this built-in tool allows you to create quick formulas based off VX Ace's default damage formula. However, the base formula produced by "Quick..." is unchangeable. Base_Value + a.atk * (0.04 * Physical) + a.mat * (0.04 * Magical) - b.def * (0.02 * Physical) - b.mdf * (0.02 * Magical) The effects of elements and defense actions are reflected elsewhere, and are therefore not included in this formula. ''Ignore Target's Defense Selecting the "Ignore Target's Defense" will simply omit the terms involving the target's DEF and MDF. Damage reduction due to states such as "Guard" will still apply. Concepts 'Return values' '"a" and "b" '''Methods 'Newline Operator (;)' Helpful Functions Random number generation, rand(x)